 <template>
	<view class="edit-page">
		<!-- 顶部栏 -->
		<view class="edit-header">
			<text class="back-arrow">＜</text>
			<text class="edit-title">信息修改</text>
			<view class="edit-actions">
				<text class="dot">•••</text>
				<text class="camera-icon">◎</text>
			</view>
		</view>
		<view class="edit-card">
			<!-- 头像选择 -->
			<view class="avatar-section">
				<view class="avatar-bar">
					<text class="cancel-btn">取消</text>
					<view class="spacer"></view>
					<text class="confirm-btn">确认</text>
				</view>
				<view class="avatar-list">
					<view v-for="(item, idx) in avatarList" :key="idx" class="avatar-item" :class="{selected: selectedAvatar === idx}" @click="selectAvatar(idx)">
						<image :src="item" class="avatar-img" />
						<view class="avatar-radio"></view>
					</view>
					<view class="avatar-item upload-item" @click="uploadAvatar">
						<view class="upload-plus">+</view>
						<text class="upload-text">上传照片</text>
					</view>
				</view>
			</view>
			<!-- 手机号和验证码 -->
			<view class="form-section">
				<view class="input-row">
					<image class="input-icon" src="/static/phone.png" />
					<input class="input" type="text" placeholder="请输入手机号码" v-model="phone" />
					<view class="input-clear" v-if="phone" @click="phone = ''">×</view>
				</view>
				<view class="input-row">
					<image class="input-icon" src="/static/shield.png" />
					<input class="input" type="text" placeholder="输入验证码" v-model="code" />
					<button class="code-btn" @click="getCode">获取验证码</button>
				</view>
				<button class="submit-btn" @click="submit">提交</button>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue'
const avatarList = ref([
	'/static/avatar1.png',
	'/static/avatar2.png',
	'/static/avatar1.png',
	'/static/avatar2.png'
])
const selectedAvatar = ref(0)
const phone = ref('')
const code = ref('')
function selectAvatar(idx) {
	selectedAvatar.value = idx
}
function uploadAvatar() {
	// 这里可以用uni.chooseImage实现上传
	uni.chooseImage({
		count: 1,
		success: (res) => {
			if (res.tempFilePaths && res.tempFilePaths.length > 0) {
				avatarList.value.push(res.tempFilePaths[0])
				selectedAvatar.value = avatarList.value.length - 1
			}
		}
	})
}
function getCode() {
	// 这里实现获取验证码逻辑
	uni.showToast({ title: '验证码已发送', icon: 'none' })
}
function submit() {
	// 这里实现提交逻辑
	uni.showToast({ title: '提交成功', icon: 'success' })
}
</script>

<style>
.edit-page {
	background: #f9f9f9;
	min-height: 100vh;
}
.edit-header {
	background: linear-gradient(135deg, #2d8cf0 60%, #5bc0eb 100%);
	padding-top: 60rpx;
	padding-bottom: 60rpx;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
}
.back-arrow {
	position: absolute;
	left: 30rpx;
	top: 60rpx;
	color: #fff;
	font-size: 40rpx;
}
.edit-title {
	color: #fff;
	font-size: 36rpx;
	font-weight: bold;
}
.edit-actions {
	position: absolute;
	right: 30rpx;
	top: 60rpx;
	display: flex;
	align-items: center;
	gap: 20rpx;
	color: #fff;
}
.edit-card {
	background: #fff;
	border-radius: 28rpx;
	margin: -60rpx 20rpx 0 20rpx;
	box-shadow: 0 2rpx 8rpx #eee;
	padding: 0 0 40rpx 0;
}
.avatar-section {
	padding: 30rpx 0 0 0;
}
.avatar-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 32rpx;
}
.cancel-btn {
	color: #222;
	font-size: 30rpx;
}
.confirm-btn {
	color: #2d8cf0;
	font-size: 30rpx;
}
.spacer {
	flex: 1;
}
.avatar-list {
	display: flex;
	flex-wrap: wrap;
	gap: 32rpx;
	padding: 32rpx;
}
.avatar-item {
	width: 160rpx;
	height: 160rpx;
	border-radius: 20rpx;
	background: #f6f6f6;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	margin-bottom: 0;
	cursor: pointer;
}
.avatar-img {
	width: 140rpx;
	height: 140rpx;
	border-radius: 16rpx;
}
.avatar-radio {
	position: absolute;
	left: 12rpx;
	top: 12rpx;
	width: 24rpx;
	height: 24rpx;
	border-radius: 50%;
	border: 4rpx solid #fff;
	background: #fff;
	box-shadow: 0 0 0 2rpx #bbb;
}
.avatar-item.selected .avatar-radio {
	background: #2d8cf0;
	box-shadow: 0 0 0 2rpx #2d8cf0;
}
.upload-item {
	flex-direction: column;
	background: #fafafa;
	border: 2rpx dashed #ccc;
}
.upload-plus {
	font-size: 60rpx;
	color: #bbb;
	margin-bottom: 10rpx;
}
.upload-text {
	color: #bbb;
	font-size: 28rpx;
}
.form-section {
	margin-top: 40rpx;
	padding: 0 32rpx;
}
.input-row {
	display: flex;
	align-items: center;
	background: #f6f6f6;
	border-radius: 40rpx;
	padding: 0 32rpx;
	margin-bottom: 32rpx;
	height: 90rpx;
	position: relative;
}
.input-icon {
	width: 40rpx;
	height: 40rpx;
	margin-right: 20rpx;
}
.input {
	flex: 1;
	border: none;
	background: transparent;
	font-size: 30rpx;
	color: #222;
	outline: none;
}
.input-clear {
	color: #bbb;
	font-size: 36rpx;
	margin-left: 10rpx;
	cursor: pointer;
}
.code-btn {
	background: #2d8cf0;
	color: #fff;
	border: none;
	border-radius: 40rpx;
	padding: 0 32rpx;
	font-size: 28rpx;
	height: 60rpx;
	margin-left: 20rpx;
}
.submit-btn {
	width: 100%;
	background: #0966e9;
	color: #fff;
	border: none;
	border-radius: 40rpx;
	font-size: 32rpx;
	padding: 24rpx 0;
	margin-top: 32rpx;
}
</style>
